Ubuntu 16.04
Sponsored Link

OpenStack Mitaka : Boot Instances
2016/05/20
 
Create and Start Virtual Machine Instance.
[1] Specify the flavor (memory or disk) and create an instance and boot it.
# default flavor list

root@dlp ~(keystone)#
nova flavor-list

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

# show the list of images

root@dlp ~(keystone)#
nova image-list

+--------------------------------------+------------+--------+--------+
| ID                                   | Name       | Status | Server |
+--------------------------------------+------------+--------+--------+
| 14679af9-2662-46ea-a40e-37820d1af5f4 | Ubuntu1604 | ACTIVE |        |
+--------------------------------------+------------+--------+--------+

# create and boot an instance

root@dlp ~(keystone)#
nova boot --flavor 2 --image Ubuntu1604 --security-groups default Ubuntu_1604

+--------------------------------------+---------------------------------------------------+
| Property                             | Value                                             |
+--------------------------------------+---------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                            |
| OS-EXT-AZ:availability_zone          |                                                   |
| OS-EXT-SRV-ATTR:host                 | -                                                 |
| OS-EXT-SRV-ATTR:hostname             | ubuntu-1604                                       |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                 |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000003                                 |
| OS-EXT-SRV-ATTR:kernel_id            |                                                   |
| OS-EXT-SRV-ATTR:launch_index         | 0                                                 |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                                   |
| OS-EXT-SRV-ATTR:reservation_id       | r-x1om1f5u                                        |
| OS-EXT-SRV-ATTR:root_device_name     | -                                                 |
| OS-EXT-SRV-ATTR:user_data            | -                                                 |
| OS-EXT-STS:power_state               | 0                                                 |
| OS-EXT-STS:task_state                | scheduling                                        |
| OS-EXT-STS:vm_state                  | building                                          |
| OS-SRV-USG:launched_at               | -                                                 |
| OS-SRV-USG:terminated_at             | -                                                 |
| accessIPv4                           |                                                   |
| accessIPv6                           |                                                   |
| adminPass                            | HgZRyvrKGQQ9                                      |
| config_drive                         |                                                   |
| created                              | 2016-05-20T12:52:12Z                              |
| description                          | -                                                 |
| flavor                               | m1.small (2)                                      |
| hostId                               |                                                   |
| host_status                          |                                                   |
| id                                   | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f              |
| image                                | Ubuntu1604 (14679af9-2662-46ea-a40e-37820d1af5f4) |
| key_name                             | -                                                 |
| locked                               | False                                             |
| metadata                             | {}                                                |
| name                                 | Ubuntu_1604                                       |
| os-extended-volumes:volumes_attached | []                                                |
| progress                             | 0                                                 |
| security_groups                      | default                                           |
| status                               | BUILD                                             |
| tenant_id                            | 61bb62a97e394b8db8f95aa05a678771                  |
| updated                              | 2016-05-20T12:52:13Z                              |
| user_id                              | 45bb5ebf547f4be2a21bf4a07c83ad85                  |
+--------------------------------------+---------------------------------------------------+

# show status

root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | BUILD  | spawning   | NOSTATE     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
[2] Login to the Instance just booted.
# after few minutes later, the Status turns "ACTIVE" like follows

root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+

# it's OK if ICMP answer replys like follows

root@dlp ~(keystone)#
ping 10.1.0.2

64 bytes from 10.1.0.2: icmp_seq=1 ttl=64 time=0.301 ms
64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.232 ms

--- 10.1.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.232/0.266/0.301/0.038 ms

# login via SSH

root@dlp ~(keystone)#
ssh xerus@10.1.0.2

The authenticity of host '10.1.0.2 (10.1.0.2)' can't be established.
ECDSA key fingerprint is 9e:7d:63:ad:c8:96:67:f3:0f:f3:bc:fc:62:81:08:63.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.0.2' (ECDSA) to the list of known hosts.
xerus@10.1.0.2's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Last login: Fri May 20 21:36:22 2016
xerus@ubuntu:~$    
# just logined

[3] If you using a virtual machine image provided from internet and do not know any password for login, Add SSH key-pair to login like follows.
# create key-pair

root@dlp ~(keystone)#
ssh-keygen -f mykey -q -N ""

# add public key

root@dlp ~(keystone)#
openstack keypair create --public-key mykey.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | b0:ff:b1:db:cd:ae:42:9d:e0:aa:81:9f:c9:87:55:1e |
| name        | mykey                                           |
| user_id     | 45bb5ebf547f4be2a21bf4a07c83ad85                |
+-------------+-------------------------------------------------+

root@dlp ~(keystone)#
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | b0:ff:b1:db:cd:ae:42:9d:e0:aa:81:9f:c9:87:55:1e |
+-------+-------------------------------------------------+

# run instance with key

root@dlp ~(keystone)#
nova boot --flavor 2 --image Ubuntu1604 --security-groups default --key-name mykey Ubuntu16_04_1
root@dlp ~(keystone)#
nova list

+--------------------------------------+---------------+---------+------------+-------------+--------------------+
| ID                                   | Name          | Status  | Task State | Power State | Networks           |
+--------------------------------------+---------------+---------+------------+-------------+--------------------+
| c778a47b-9879-42bb-a949-1e9e26cbb35f | Ubuntu16_04_1 | ACTIVE  | -          | Running     | network01=10.1.0.6 |
+--------------------------------------+---------------+---------+------------+-------------+--------------------+

# ssh with the key and a default user (Ubuntu's default user is just "ubuntu")

root@dlp ~(keystone)#
ssh -i mykey ubuntu@10.1.0.6
ubuntu@ubuntu16-04-1:~$    
# just logined

[4] If you'd like to stop an instance, it's also possible to control with nova command like follows.
root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+

# stop instance

root@dlp ~(keystone)#
nova stop Ubuntu_1604

Request to stop server Ubuntu_1604 has been accepted.
root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | SHUTOFF | -          | Running     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+

# start instance

root@dlp ~(keystone)#
nova start Ubuntu_1604

Request to start server Ubuntu_1604 has been accepted.
root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
[5] It's possible to access with Web browser to get VNC console.
root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks           |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+
| 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+--------------------+

root@dlp ~(keystone)#
nova get-vnc-console Ubuntu_1604 novnc

+-------+--------------------------------------------------------------------------------+
| Type  | Url                                                                            |
+-------+--------------------------------------------------------------------------------+
| novnc | http://10.0.0.30:6080/vnc_auto.html?token=9a44fd6f-cfe2-4593-9be1-93ae80244e7b |
+-------+--------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by "get-vnc-console" like follows.
 
Tweet